<?php

namespace backend\models;

use Yii;
use yii\base\Model;
use yii\web\UploadedFile;

/**
 * This is the model class for table "shop".
 *
 * @property int $id
 * @property string|null $shop_id 店铺id
 * @property string|null $shop_name 店铺名称
 * @property int|null $settled_time 入驻时间
 * @property int|null $check_status 审核状态 0未审核 1审核
 * @property string|null $shop_desc 店铺介绍
 * @property int|null $created_at 添加时间
 */
class Shop extends \yii\db\ActiveRecord
{

    public $image;

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'shop';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['settled_time', 'check_status', 'created_at'], 'integer'],
            [['shop_desc'], 'string'],
            [['shop_id'], 'string', 'max' => 10],
            [['shop_name'], 'string', 'max' => 100],
            [['shop_image'], 'string'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'shop_name' => '店铺名称',
            'settled_time' => '入驻时间',
            'check_status' => '审核状态',
            'shop_desc' => '店铺详述',
            'image'=>'店铺图片',
        ];
    }


    public function upload()
    {
        if ($this->validate()) {
            $this->image->saveAs('uploads/' . $this->image->baseName . '.' . $this->image->extension);
            return true;
        } else {
            return false;
        }
    }
}
